<template>
<div>
  <van-field v-model="title" label="小说标题"/><br>
  <br>
  <textarea name="" id="" cols="100" rows="20" v-model="content" placeholder="请输入内容"></textarea>
  <br>
  <button @click="add">提交</button>
</div>
</template>

<script>
import  axios from 'axios'
export default {
  name: "xiaoshuo",
  data(){
    return{
      title:'',
      content:'',
      userid:localStorage.getItem('userid')
    }
  },
  methods:{
    add(){
      axios({url:'http://localhost:8000/addxiaoshuo/',method:'post',data:{'title':this.title,'content':this.content,'userid':this.userid}}).then(res=>{
        if(res.data.code==200){
          this.$toast.success('小说提交成功')
        }else {
          this.$toast.success('小说提交失败')
        }
      })
    }
  }
}
</script>

<style scoped>

</style>